<template>
				<div class="link_wx">
					<wx-open-launch-weapp
					  id="launch-btn"
					  username="gh_1275768357c8"
					  path="pages/index/index.html"
					  @error="handleErrorFn"
					  @launch="handleLaunchFn"
					>
					  <script type="text/wxtag-template">
					    <style>.indexbtn { background: url(img/wx_patient/link_wxindex.png)no-repeat; }</style>
					    <button class="btn indexbtn"></button>
					  </script>
					</wx-open-launch-weapp>

				</div>
				<div class="link_wx" v-if="detail.buyPackage==0">
					<wx-open-launch-weapp
					  id="launch-btn"
					  username="gh_1275768357c8"
					  path="pages/index/index.html"
					  @error="handleErrorFn"
					  @launch="handleLaunchFn"
					>
					  <script type="text/wxtag-template">
					    <style>.servicebtn { background: url(img/wx_patient/wx_service_1.png)no-repeat; }</style>
					    <button class="btn servicebtn"></button>
					   
					  </script>
					</wx-open-launch-weapp>

				</div>
				<div class="link_wx" v-if="detail.buyPackage==1">
					<wx-open-launch-weapp
					  id="launch-btn"
					  username="gh_1275768357c8"
					  path="pages/index/index.html"
					  @error="handleErrorFn"
					  @launch="handleLaunchFn"
					>
					  <script type="text/wxtag-template">
					    <style>.servicebtn { background: url(img/wx_patient/wx_service_2.png)no-repeat; }</style>
					    <button class="btn servicebtn"></button>
					   
					  </script>
					</wx-open-launch-weapp>

				</div>
				</template>
<script>
import {
			getAction,
			postAction,
			spliceUrl,
		} from "../../common/js/api/vue3-axios-utils.js";
export default {
    methods: {
    	openWxmini(){
	           		postAction(spliceUrl('/sys/wechat/signature'),{pageUrl:window.location.href}).then((res) => {
						res = res.data
						console.log('openWxmini',res)
						if(res.success){
							let result = res.result
							wx.config({
								debug: true, // 调试时可开启
								appId: result.appId, // <!-- replace -->
								timestamp: result.timestamp, // 必填，填任意数字即可
								nonceStr: result.nonceStr, // 必填，填任意非空字符串即可
								signature: result.signature, // 必填，填任意非空字符串即可
								jsApiList: ['chooseImage', 'previewImage'], // 必填，随意一个接口即可 
								openTagList: ['wx-open-launch-weapp'], // 填入打开小程序的开放标签名
							})
							wx.ready(function () {
						    	})
						    	wx.error(function (res) {
						        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名
						        console.log('wx.error',res)
						    	});
						}
					})
	           	}, 
	           	handleErrorFn(e){
			        console.log('fail', e.detail);
			    },
				handleLaunchFn(e){
			        console.log('success');
			  	},
        
    },
    created() {
        const oScript = document.createElement('script');
        oScript.type = 'text/javascript';
        oScript.src = 'https://res2.wx.qq.com/open/js/jweixin-1.6.0.js';
        oScript.onload = this.openWxmini
        document.body.appendChild(oScript);
    },
}
</script>